﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.Mvc;
using System.Web.Mvc.Html;

namespace Bzure.Mvc.Html
{
    public static class RenderThemePartialExtensions
    {
        public static void RenderThemeAreaPartial(this HtmlHelper htmlHelper, string AreaName, string partialViewName)
        {
            string ThemeName = htmlHelper.ViewContext.RequestContext.GetThemeName();
            htmlHelper.RenderPartial(FilterpartialViewName(htmlHelper, AreaName, partialViewName));
        
        }
        public static void RenderThemePartial(this HtmlHelper htmlHelper, string partialViewName)
        {
            htmlHelper.RenderThemeAreaPartial(null, partialViewName);
        }


        public static void RenderThemeAreaPartial(this HtmlHelper htmlHelper, string AreaName, string partialViewName, ViewDataDictionary viewData)
        {
            htmlHelper.RenderPartial(FilterpartialViewName(htmlHelper, AreaName, partialViewName), viewData);
        }
        public static void RenderThemePartial(this HtmlHelper htmlHelper, string partialViewName, ViewDataDictionary viewData)
        {
            htmlHelper.RenderThemeAreaPartial(null, partialViewName, viewData);
        }


        public static void RenderThemeAreaPartial(this HtmlHelper htmlHelper, string AreaName, string partialViewName, object model)
        {
            htmlHelper.RenderPartial(FilterpartialViewName(htmlHelper, AreaName, partialViewName), model);
        }
        public static void RenderThemePartial(this HtmlHelper htmlHelper, string partialViewName, object model)
        {
            htmlHelper.RenderThemeAreaPartial(null, partialViewName, model);
        }



        public static void RenderThemeAreaPartial(this HtmlHelper htmlHelper, string AreaName, string partialViewName, object model, ViewDataDictionary viewData)
        {
            htmlHelper.RenderPartial(FilterpartialViewName(htmlHelper, AreaName, partialViewName), model, viewData);
        }
        public static void RenderThemePartial(this HtmlHelper htmlHelper,  string partialViewName, object model, ViewDataDictionary viewData)
        {
            htmlHelper.RenderThemeAreaPartial(null, partialViewName, model, viewData);
        }


        static string FilterpartialViewName(HtmlHelper htmlHelper, string AreaName, string partialViewName)
        {
            return ThemeHelper.CreateThemeViewPath(htmlHelper.ViewContext.RequestContext.GetThemeName(), AreaName, partialViewName);
        }
    }


    public static class RenderGenericThemePartialExtensions
    {
        public static void RenderGenericThemeAreaPartial(this HtmlHelper htmlHelper, string AreaName, string partialViewName)
        {
            string ThemeName = htmlHelper.ViewContext.RequestContext.GetThemeName();
            htmlHelper.RenderPartial(FilterPartialViewName(htmlHelper, AreaName, partialViewName));
        }
        public static void RenderGenericThemePartial(this HtmlHelper htmlHelper, string partialViewName)
        {
            htmlHelper.RenderGenericThemeAreaPartial(null, partialViewName);
        }


        public static void RenderGenericThemeAreaPartial(this HtmlHelper htmlHelper, string AreaName, string partialViewName, ViewDataDictionary viewData)
        {
            htmlHelper.RenderPartial(FilterPartialViewName(htmlHelper, AreaName, partialViewName), viewData);
        }
        public static void RenderGenericThemePartial(this HtmlHelper htmlHelper, string partialViewName, ViewDataDictionary viewData)
        {
            htmlHelper.RenderGenericThemeAreaPartial(null, partialViewName, viewData);
        }


        public static void RenderGenericThemeAreaPartial(this HtmlHelper htmlHelper, string AreaName, string partialViewName, object model)
        {
            htmlHelper.RenderPartial(FilterPartialViewName(htmlHelper, AreaName, partialViewName), model);
        }
        public static void RenderGenericThemePartial(this HtmlHelper htmlHelper, string partialViewName, object model)
        {
            htmlHelper.RenderGenericThemeAreaPartial(null, partialViewName, model);
        }



        public static void RenderGenericThemeAreaPartial(this HtmlHelper htmlHelper, string AreaName, string partialViewName, object model, ViewDataDictionary viewData)
        {
            htmlHelper.RenderPartial(FilterPartialViewName(htmlHelper, AreaName, partialViewName), model, viewData);
        }
        public static void RenderGenericThemePartial(this HtmlHelper htmlHelper, string partialViewName, object model, ViewDataDictionary viewData)
        {
            htmlHelper.RenderGenericThemeAreaPartial(null, partialViewName, model, viewData);
        }


        static string FilterPartialViewName(HtmlHelper htmlHelper, string AreaName, string partialViewName)
        {
            return ThemeHelper.CreateGenericThemeViewPath( AreaName, partialViewName);
        }
    }
}
